<?php

namespace App\Http\Controllers\Api\V2;

use App\Services\Gallery\Interfaces\SpaceSchemeServiceInterface;
use App\Services\Gallery\Services\SpaceSchemeService;

use App\Services\Gallery\Interfaces\SpaceSchemeContentCategoryServiceInterface;
use App\Services\Gallery\Services\SpaceSchemeContentCategoryService;

use Illuminate\Http\Request;


class SpaceSchemeController extends BaseController
{
    /**
     * @var SpaceSchemeService
     */
    protected $SpaceSchemeService;

    /**
     * @var SpaceSchemeContentCategoryService
     */
    protected $SpaceSchemeContentCategoryService;

    public function __construct(SpaceSchemeServiceInterface $SpaceSchemeService,SpaceSchemeContentCategoryServiceInterface $SpaceSchemeContentCategoryService)
    {
        $this->SpaceSchemeService = $SpaceSchemeService;
        $this->SpaceSchemeContentCategoryService = $SpaceSchemeContentCategoryService;
    }

    public function index(Request $request)
    {
        $spaceSchemes = $this->SpaceSchemeService->index($request->all());
        $data = arr2_clear($spaceSchemes["data"], ["id", "title", "thumb", "sort", 'updated_at','acreage']);
        $spaceSchemes['data'] = $data;
        return $this->data($spaceSchemes);
    }

    public function detail($id)
    {
        $spaceScheme = $this->SpaceSchemeService->get($id);
        return $this->data($spaceScheme);
    }

    public function contentedit($id)
    {
        $space_scheme_content_category = $this->SpaceSchemeContentCategoryService->getcontent($id);
        foreach($space_scheme_content_category as $key => $data){
            $space_scheme_content_category[$key]["contentes"] = arr2_clear($data["contentes"], ["id","title","thumb","url","sort"]);
        }
        $space_scheme_content_category = arr2_clear($space_scheme_content_category, ["id","title","space_scheme_id","contentes","sort",'type']);
        return $this->data($space_scheme_content_category);
    }

}
